package com.zxwl.base.service;

import java.io.Serializable;
import java.util.List;

import com.zxwl.base.dao.DataPage;
import com.zxwl.base.dao.IBaseDao;
import com.zxwl.base.dao.QueryParameter;



public abstract class  BaseService<E> implements IBaseService<E>
{
	protected IBaseDao<E> dao;

	@SuppressWarnings("hiding")
	public <E>BaseService()
	{
	}
	public IBaseDao<E> getDao()
	{
		return dao;
	}
	
	public abstract void setDao(IBaseDao<E> dao);
	
	
	public E createEntity() throws InstantiationException, IllegalAccessException
	{
		return this.dao.createEntity();
	}
	
	@Override
	public List<E> queryForPage(DataPage<E> dataPage)
	{
		return dao.queryForPage(dataPage);
	}

	@Override
	public E query(Serializable id)
	{
		return dao.queryById(id);
	}

	@Override
	public void save(E entity)
	{
		dao.save(entity);
	}

	@Override
	public void update(E entity)
	{
		dao.update(entity);		
	}

	@Override
	public void delete(Serializable id)
	{
		dao.delete(id);
	}

	@Override
	public List<E> queryList(QueryParameter queryParameter)
	{
		return dao.queryList(queryParameter);
	}
	
	@Override
	public Boolean isChanged(E entity)
	{
		return dao.isChanged(entity);
	}
}
